package com.itheim.service.impl;

import com.itheim.mapper.EmpMapper;
import com.itheim.mapper.StudentMapper;
import com.itheim.pojo.clazzOption;
import com.itheim.pojo.jobOption;
import com.itheim.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ReportServiceImp implements ReportService {

    @Autowired
    private EmpMapper empMapper;
    @Autowired
    private StudentMapper studentMapper;

    @Override
    public jobOption getEmpJobData() {
        List<Map<String, Object>> list = empMapper.getJobData();
        List<Object> jobList =list.stream().map(dataMap->dataMap.get("pos")).toList();
        List<Object> dataList =list.stream().map(dataMap->dataMap.get("num")).toList();
        return new jobOption(jobList,dataList);
    }

    @Override
    public List<Map<String, Object>> getEmpGenderData() {
        List<Map<String, Object>> list = empMapper.getGenderData();
        return list;
    }

    @Override
    public clazzOption getStudentCountData() {
        List<Map<String, Object>> list = studentMapper.getStudentCountData();
        List<Object> clazzList =list.stream().map(dataMap->dataMap.get("name")).toList();
        List<Object> dataList =list.stream().map(dataMap->dataMap.get("value")).toList();
        return new clazzOption(clazzList,dataList);
    }

    @Override
    public List<Map<String, Object>> getStudentDegreeData() {
        List<Map<String, Object>> list = studentMapper.getStudentDegreeData();
        return list;
    }
}
